<?php
namespace modules\system\action\show;

use library\PageAction;
use idea\ap\Ap;
use helper\Util;

/**
 * OptionsAction class file
 * 项目站点配置
 * @author 宋欢 <iphper@yeah.net>
 * @version $Id: OptionsAction.php 1 2013-02-08 00:48:06Z huan.song $
 * @package modules.system.action.show
 * @since 1.0
 */
class OptionsAction extends PageAction
{
	public function run()
	{
		$request = Ap::getRequest();
		$category = $request->getInteger('category');
		$do = $request->getParam('do');
		if ($do === 'post') {
			Util::getService('options', 'system')->save($category, $request->getPost());
		}

		$ret = Util::getService('options', 'system')->findAll();
		$ret['category'] = $category > 0 ? $category : 1;
		$this->render($ret);
	}
}
